package com.kotlin.mvpdemo.ui.users.presenter;

import android.util.Log;

import androidx.lifecycle.Observer;

import com.kotlin.mvpdemo.base.BasePresenter;
import com.kotlin.mvpdemo.entity.ChaptersEntity;
import com.kotlin.mvpdemo.ui.users.view.UserListView;

import java.util.ArrayList;

/**
 * author : fang.zhang
 * e-mail : initzf@126.com
 * date   : 2020/6/6
 * desc   : 用户列表逻辑处理类
 */
public class UserListPresenter extends BasePresenter<UserListView> {
    private static final String TAG = "UserListPresenter";

    @Override
    protected void onCreate() {
        super.onCreate();
        Log.i(TAG, "onCreate: ");
    }

    public void getData() {
        exceute(mApi.getChapters(), new ArrayList<ChaptersEntity>()).observe(getOwner(), new Observer<ArrayList<ChaptersEntity>>() {
            @Override
            public void onChanged(ArrayList<ChaptersEntity> chaptersEntities) {
                Log.i(TAG, "onChanged: ");
                if (chaptersEntities == null) {
                    return;
                }
                mView.userList(chaptersEntities);
            }
        });
    }
}
